/*
 * BanBu_PlayButton
 * @description 本文件提供个人空间定制的播放按钮
 * @package
 * @author 		***
 * @copyright
 * @version 		1.0
 * @description 本文件提供个人空间定制的播放按钮
 */

#import "BanBu_PlayButton.h"

@implementation BanBu_PlayButton

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

    }
    return self;
}

-(void)setMode:(MusicPlayMode)mode
{
    _mode = mode;
    [self refreshButtonAppearance];
}
-(void)refreshButtonAppearance
{
    switch (_mode) {
        case MusicPlayLoadingMode:
        {
            if(!loadingView)
            {
                loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
                loadingView.center = CGPointMake(self.frame.size.width/2, self.frame.size.height/2);
                [loadingView setHidesWhenStopped:YES];
                [self addSubview:loadingView];
            }
            [loadingView startAnimating];
            [self setBackgroundImage:[UIImage imageNamed:@"voiceDataLoading.png"] forState:UIControlStateNormal];
        }
            break;
        case MusicPlayPlayingMode:
        {
            [loadingView stopAnimating];
            [self setBackgroundImage:[UIImage imageNamed:@"voiceDataClose.png"] forState:UIControlStateNormal];
        }
            break;
        case MusicPlayStopedMode:
        {
            [loadingView stopAnimating];
            [self setBackgroundImage:[UIImage imageNamed:@"voiceDataOpen.png"] forState:UIControlStateNormal];
        }
            break;
        default:
            break;
    }
}
- (void)dealloc
{
    if (loadingView) { [loadingView release],loadingView = nil; }
    
    [super dealloc];
}
@end
